import { createStore } from 'vuex'

export default createStore({
  state: {
    address:null,
  },
  getters: {
  },
  mutations: {
    setAddress(state, val) {
      if(val){
        state.address = val;
        localStorage.setItem('address',val)
      }else{
        state.address = null;
        localStorage.removeItem('address')
      }
    },
  },
  actions: {
    add_actions(context, val) {
        context.commit('setAddress', val)  // 通过context去触发mutions中的sum
    }
  },
  modules: {
  }
})
